<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="myCart">
        商品1的数量：<input type="text" v-model="num1"><br>
        商品1的价格：<input type="test" v-model="price1"><br>
        商品2的数量：<input type="text" v-model="num2"><br>
        商品2的价格：<input type="test" v-model="price2">
        总价格：{{total()}}
    </div>
    <script src="js/vue.global.js"></script>
    <script>
        const CounterApp = {
            data() {
                return {
                    num1: 1,
                    price1: 10,
                    num2: 2,
                    price2: 20
                }
            },
            // computed: {
            //     total() {
            //         return this.num1 * this.price1 + this.num2 * this.price2
            //     }
            // },
            methods: {
                total() {
                    return this.num1 * this.price1 + this.num2 * this.price2
                }
            }
        }
        Vue.createApp(CounterApp).mount('#myCart')

    </script>
</body>

</html>